#pragma once

#include "Common/AtomicVal.h"

class IDGen
{
public:
	IDGen( UInt32 maxId_ = 0 )
		: _maxId( maxId_ ) 
	{
	}

public:
	virtual UInt32 genId()
	{
		return ++ _maxId;
	}
	inline void setMaxId( UInt32 id_ )
	{
		if( _maxId < id_ )
			_maxId = id_;
	}

protected:
	AtomicVal<UInt32> _maxId;
};

class SessionIDGen
	: public IDGen
{
public:
	SessionIDGen( UInt32 maxId_ = 0 )
		: IDGen( maxId_ )
	{
	}
};


extern SessionIDGen sessionIDGen;